package com.yequan.hbb.model;

import com.yequan.hbb.entries.QuestionEntries;
import com.yequan.hbb.servers.Servers;
import com.yequan.hbb.utils.ServerUtil;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by DingLong on 2016/10/14.
 */

public class QuesrionModel extends MVPModel {
    private QuesrionCallBack quesrionCallBack;

    public QuesrionModel(QuesrionCallBack quesrionCallBack) {
        this.quesrionCallBack = quesrionCallBack;
    }

    public void getData(int contentId) {
        Call<QuestionEntries> call = ServerUtil.createHttpRequest(Servers.class).getQuestionInfo(contentId);
        call.enqueue(new Callback<QuestionEntries>() {
            @Override
            public void onResponse(Call<QuestionEntries> call, Response<QuestionEntries> response) {
                quesrionCallBack.onResponse(call,response);
            }

            @Override
            public void onFailure(Call<QuestionEntries> call, Throwable t) {
                quesrionCallBack.onFailure(call,t);
            }
        });
    }

    public interface QuesrionCallBack {
        void onResponse(Call<QuestionEntries> call, Response<QuestionEntries> response);

        void onFailure(Call<QuestionEntries> call, Throwable t);
    }
}
